package cn.ultrawise.planeshootinggame;

import cn.ultrawise.view.ProgressView;
import cn.ultrawise.view.WelcomeView;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.app.Activity;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class PlaneActivity extends Activity {  
	private static final int TOWELCOMEVIEW = 1 ;
	public ProgressView progressView ;
	public WelcomeView welcomeView ;
	private int tableWidth ;
	private int tableHeight ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE) ;
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
        		,WindowManager.LayoutParams.FLAG_FULLSCREEN) ;
        WindowManager windowManager = getWindowManager() ;
        Display display = windowManager.getDefaultDisplay() ;
        tableWidth = display.getWidth() ;
        tableHeight = display.getHeight() ;
        progressView = new ProgressView(this,PlaneActivity.this) ;
        setContentView(progressView);
        new Thread(new Runnable() {
			public void run() {
				Looper.prepare() ;
				welcomeView = new WelcomeView(PlaneActivity.this,PlaneActivity.this,tableWidth,tableHeight) ;
			}
		}).start() ;
    }
    public Handler myhandler = new Handler(){

		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case TOWELCOMEVIEW:
				toContentView(welcomeView) ;
				break;
			default:
				break;
			}
		}
    	
    } ;
    public void toContentView(View v){
    	this.setContentView(v) ;
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.plane, menu);
        return true;
    }
    
}
